<?php
//设置响应头
header("content-type:text/html;charset=utf-8");
//获取客户端传入的参数
$id=$_GET['id'];
$name=$_GET['name'];
$pass=$_GET['pass'];

//连接数据库
$link=mysqli_connect('localhost','root','','shop');

//设置编码
mysqli_set_charset($link,"utf8");
//SQL语句
$sql="select * from user2 where id=$id and name='$name'";
//执行SQL，并返回结果集
$result=mysqli_query($link,$sql);

//检查结果集是否有数据
if(mysqli_fetch_row($result)){
    echo "1";

}else{
    $sql2="insert into user2 values($id,'$name','$pass')";
    $result2 = mysqli_query($link,$sql2);
    echo "0";
}

//关闭数据库
mysqli_close($link);

?>
